Skip to content

Fix pause container of a privileged pod unable to start due to /sys mount option mismatch#2760

Merged
anmaxvl merged 4 commits into
microsoft:mainfrom
micromaomao:pause-container-sysfs
Jun 17, 2026
Merged

Fix pause container of a privileged pod unable to start due to /sys mount option mismatch#2760
anmaxvl merged 4 commits into
microsoft:mainfrom
micromaomao:pause-container-sysfs

Conversation

@micromaomao

@micromaomao micromaomao commented Jun 1, 2026

Copy link
Copy Markdown
Member

Starting with v2, containerd mounts /sys as rw on the sandbox container when the
pod is privileged (1fc497218 "Fix privileged container sysfs can't be rw because
pod is ro by default") instead of ro. This means that the mount list for a
privileged pause container no longer matches with just data.defaultMounts and
will need a special case for sysfs. Alternative options were also considered -
see the comment in framework.rego.

This change in GCS is necessary even though this can be fixed via a policy
change, because we need to maintain compatibility with existing policies.

This PR converts EnforceCreateContainerPolicy in the LCOW GCS to
EnforceCreateContainerPolicyV2, in order to use the CreateContainerOptions
struct to pass an additional bool indicating whether the current container is a
sandbox container.

This does not allow additional capabilities etc for the sandbox container, only
that sysfs can now be rw.

Assisted-by: GitHub Copilot:claude-opus-4.7
Signed-off-by: Tingmao Wang tingmaowang@microsoft.com

@micromaomao micromaomao requested a review from a team as a code owner June 1, 2026 08:25
@micromaomao micromaomao marked this pull request as draft June 1, 2026 08:26
@micromaomao micromaomao force-pushed the pause-container-sysfs branch 2 times, most recently from eefdbba to a10d1a1 Compare June 1, 2026 22:51
@micromaomao micromaomao requested a review from Copilot June 1, 2026 23:06
@micromaomao micromaomao marked this pull request as ready for review June 1, 2026 23:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds an IsSandboxContainer flag to CreateContainerOptions and threads it through the Rego policy enforcer so that the framework policy can special-case a /sys rw mount on the CRI pod sandbox (pause) container when the policy allows any elevated containers.

Changes:

  • New IsSandboxContainer field on CreateContainerOptions, populated from c.isSandbox in Host.CreateContainer and forwarded into the Rego input.
  • New mount_ok rule in framework.rego that permits a sysfs rw /sys mount for the sandbox container when at least one candidate container has allow_elevated.
  • Tests covering sandbox vs. non-sandbox, ro/rw combinations, and the privileged-request-denied case.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pkg/securitypolicy/securitypolicyenforcer.go Adds IsSandboxContainer field with doc comment.
pkg/securitypolicy/securitypolicyenforcer_rego.go Plumbs the flag through V1 wrapper and into the Rego input map.
pkg/securitypolicy/framework.rego New mount_ok rule for sandbox sysfs rw carve-out; minor whitespace cleanup.
pkg/securitypolicy/regopolicy_linux_test.go New tests for sandbox sysfs carve-out behavior.
internal/guest/runtime/hcsv2/uvm.go Switches to EnforceCreateContainerPolicyV2 and supplies IsSandboxContainer: c.isSandbox.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/securitypolicy/framework.rego Outdated
Comment thread pkg/securitypolicy/framework.rego
Comment thread pkg/securitypolicy/regopolicy_linux_test.go Outdated
Comment thread pkg/securitypolicy/regopolicy_linux_test.go Outdated
@micromaomao micromaomao force-pushed the pause-container-sysfs branch 2 times, most recently from e931899 to a49098b Compare June 2, 2026 10:10
@micromaomao

Copy link
Copy Markdown
Member Author

@anmaxvl don't forget to merge

…ount option mismatch

Starting with v2, containerd mounts /sys as rw on the sandbox container when the
pod is privileged (1fc497218 "Fix privileged container sysfs can't be rw because
pod is ro by default") instead of ro.  This means that the mount list for a
privileged pause container no longer matches with just data.defaultMounts and
will need a special case for sysfs.  Alternative options were also considered -
see the comment in framework.rego.

This change in GCS is necessary even though this can be fixed via a policy
change, because we need to maintain compatibility with existing policies.

This PR converts EnforceCreateContainerPolicy in the LCOW GCS to
EnforceCreateContainerPolicyV2, in order to use the CreateContainerOptions
struct to pass an additional bool indicating whether the current container is a
sandbox container.

This does not allow additional capabilities etc for the sandbox container, only
that sysfs can now be rw.

Assisted-by: GitHub Copilot:claude-opus-4.7
Signed-off-by: Tingmao Wang <tingmaowang@microsoft.com>
Assisted-by: GitHub Copilot:claude-opus-4.7
Signed-off-by: Tingmao Wang <tingmaowang@microsoft.com>
…for sysfs rw special case

Signed-off-by: Tingmao Wang <tingmaowang@microsoft.com>
… container in the policy is elevated

Assisted-by: GitHub Copilot copilot-review
Signed-off-by: Tingmao Wang <tingmaowang@microsoft.com>
@micromaomao micromaomao force-pushed the pause-container-sysfs branch from 18fb719 to 3f3657f Compare June 17, 2026 12:02

@micromaomao micromaomao left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed the

    some c in candidate_containers
    c.allow_elevated

clause since even when a policy does not allow any elevated containers, some future fragments might do, Noticed in testing, fix pushed.

@anmaxvl anmaxvl merged commit 86fcff2 into microsoft:main Jun 17, 2026
19 checks passed
@micromaomao micromaomao deleted the pause-container-sysfs branch June 17, 2026 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants